package io.sage.common.utils;

import org.springframework.util.ObjectUtils;

/**
 * Created by Mafy on 2019/2/27.
 */
public class CheckNullUtils {

    /**
     * 参数验证1 -获取为空字段下标
     * @param param
     * @return
     */
    public static int checkNotNullParam(Object... param){
        for (int i = 0; i < param.length; i++) {
            if (ObjectUtils.isEmpty(param[i])){
                return i;
            }
        }
        return -1;
    }

    /**
     *  参数验证2 提示信息
     * @param index 下标
     * @param param 参数名
     * @return
     */
    public static String getNullParamName(int index, String... param){
        if (index == -1){
            return "0";
        }
        if (param.length>=index+1){
            return param[index]+" 不可为空";
        }
        return "0";
    }
}
